package com.rgs.se.sort;

public class _1Shell {
    public static void Shell(int[] arr){
        //双层循环，外层控制增量，内层控制排序
        for (int interval = arr.length/2; interval > 0; interval=interval/2) {
            //每个元素在自己的组里进行插入排序
            for (int i = interval; i < arr.length; i++) {
                int target = arr[i];
                int j = i-interval;
                while(j>-1 && target < arr[j]){
                    arr[j+interval] = arr[j];
                    j-= interval;
                }
                arr[j+interval] = target;
            }
        }

    }
}
